export CC = gcc
export CFLAGS = -Wall -g
LIBS = -lglut -lGLU -lGL -lm

all: space_simulation space_simulation_2d explosion_2d explosion_3d

space_simulation: space_simulation.o Simulation.o Vector3D.o Particule.o physic.o display/glut_3d.o CSV.o
	$(CC) $(CFLAGS) $(LIBS) -o $@ $^

space_simulation_2d: space_simulation.o Simulation.o Vector3D.o Particule.o physic.o display/glut_2d.o display/utils.o CSV.o
	$(CC) $(CFLAGS) $(LIBS) -o $@ $^

explosion_2d: explosion.o Simulation.o Vector3D.o Particule.o physic.o display/glut_2d.o display/utils.o
	$(CC) $(CFLAGS) $(LIBS) -o $@ $^

explosion_3d: explosion.o Simulation.o Vector3D.o Particule.o physic.o display/glut_3d.o
	$(CC) $(CFLAGS) $(LIBS) -o $@ $^
	
display/glut_3d.o: display/glut_3d.c display/display.h
	$(MAKE) glut_3d.o -C display

display/glut_2d.o: display/glut_2d.c display/utils.c display/display.h
	$(MAKE) glut_2d.o -C display

display/utils.o: display/utils.c
	$(MAKE) utils.o -C display

%.o: %.c
	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) -c

clean:
	rm *.o space_simulation space_simulation_2d explosion_2d explosion_3d
	$(MAKE) clean -C display
